package com.myz.rabbitmq.utils;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;


public class RabbitMqUtils {
    // 创建一个连接的channel
    public static Channel getChannel() throws Exception{
        // 创建一个连接工厂
        ConnectionFactory factory = new ConnectionFactory();
        // 设置ip 用户名 密码
        factory.setHost("192.168.56.134");
        factory.setUsername("root");
        factory.setPassword("123456");
        // 获取一个连接
        Connection connection = factory.newConnection();
        // 通过连接获取一个信道
        Channel channel = connection.createChannel();
        return channel;
    }
}
